package com.xl.qa.enmus;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.experimental.Accessors;

import java.util.Arrays;

/**
 * @author 钟勇
 * Create in 2024/1/16 15:51
 */
@Getter
@Accessors(chain = true)
@AllArgsConstructor
public enum QuestionOrderStateEnums {
    add(1, "待支付"),
    paid(2, "已支付"),
    finish(3, "已完成"),
    paymentTimeout(-1, "支付超时"),
    cancel(-2, "取消"),
    ;

    private final Integer state;
    private final String desc;


    public static QuestionOrderStateEnums getByState(Integer state) {
        if (state == null) {
            return null;
        }

        return Arrays.stream(values())
                .filter(item -> item.getState().equals(state))
                .findFirst().orElse(null);

    }
}
